package org.linlinjava.litemall.wx.web;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallDistributionRule;
import org.linlinjava.litemall.db.service.LitemallDistributionRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/wx/distributionRule")
public class WxDistributionRuleController {

    @Autowired
    private LitemallDistributionRuleService distributionRuleService;

    /**
     * 新增分销规则
     * @param distributionRule
     * @return
     */
    @PostMapping("/add")
    public Object add(@RequestBody LitemallDistributionRule distributionRule) {
        distributionRuleService.add(distributionRule);
        return ResponseUtil.ok();
    }

    /**
     * 修改分销规则
     * @param distributionRule
     * @return
     */
    @PostMapping("/update")
    public Object update(@RequestBody LitemallDistributionRule distributionRule) {
        distributionRuleService.update(distributionRule);
        return ResponseUtil.ok();
    }

    /**
     * 查询某个具体的分销规则
     * @param id
     * @return
     */
    @GetMapping("/detail")
    public Object findById(@RequestParam Integer id) {
        return ResponseUtil.ok(distributionRuleService.findById(id));
    }

    /**
     * 删除某个分销规则
     * @param id
     * @return
     */
    @PostMapping("/delete")
    public Object delete(@RequestBody Integer id) {
        return ResponseUtil.ok(distributionRuleService.delete(id));
    }




}
